﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace LocalizationTest.Tools
{
  class ConfigTool
  {
    public static List<string> GetSection(string fileName, string sectionName)
    {
      List<string> toReturn = new List<string>();
      StreamReader streamReader = new StreamReader(fileName);
      bool sectionFound = false;
      while (!streamReader.EndOfStream)
      {
        string currentLine = streamReader.ReadLine();

        if (sectionFound)
        {
          if (currentLine.Contains("[") && currentLine.Contains("]")) return toReturn;
          currentLine = currentLine.Trim().Replace("\t", "");
          if (currentLine != "" && !currentLine.StartsWith("//")) toReturn.Add(currentLine);
        }
        if (currentLine.Contains("[" + sectionName + "]"))
        {
          sectionFound = true;
        }
      }
      return toReturn;
    }
  }
}
